package wizard;

import java.awt.Component;

import javax.swing.JDialog;
import javax.swing.JPanel;

/**
 * 
 * @author michau
 *
 */

/**
 * Base class describing what methods panel may/should have and how it should behave. 
 * Override this class to add methods to set the order of panels.
 */
public class WizardPanelDescriptor {
	/**
	 * 
	 * This will be returned by getNextPanelDescriptor if the current panel is the last one.
	 */
	public static final String FINISH_IDENTIFIER = "FINISH";
	
	private Wizard wizard;
	private Component targetPanel;
	private String panelIdentifier;
	

	public WizardPanelDescriptor(){
		panelIdentifier = "defaultPanelDescriptor";
		targetPanel = new JDialog();
	}
	
	/**
	 * Constructor that accepts panel identifier and a referece to the Component class which
	 * makes up the panel.
	 * @param id String identifier.
	 * @param panel Some class that extends java.awt.Component that will be the panel.
	 */
	public WizardPanelDescriptor(String id, Component panel){
		panelIdentifier = id;
		targetPanel = panel;
	}
	
	/**
	 * Cannot be overridden.
	 * @return Component that serves as a panel.
	 */
	public final Component getPanelComponent(){
		return targetPanel;
	}
	
    public final void setPanelComponent(Component panel) {
        targetPanel = panel;
    }
    
    public final String getPanelDescriptorIdentifier(){
    	return panelIdentifier;
    }
    
    public final void setPanelDescriptorIdentifier(String id){
    	panelIdentifier = id;
    }
    
    final void setWizard(Wizard w){
    	wizard = w;
    }
    
    public final Wizard getWizard(){
    	return wizard;
    }
    
    public final WizardModel getWizardModel(){
    	return wizard.getModel();
    }
    
    // Methods to override in order to get the order of panels.
    
    /**
     * Override this method. If the current panel is the last panel
     * this method should return "FINISH" or null value.
     * @return String next panel identifier. If there is no next panel
     * returns String "FINISH" or null value.
     */
    public String getNextPanelDescriptor(){
    	return null;
    }
    
    public String getBackPanelDescriptor(){
    	return null;
    }
    
    // methods to override specifying behaviour of the panel
    
    public void aboutToDisplayPanel(){
    	
    }
    
    public void aboutToHidePanel(){
    	
    }
    
    /**
     * override this method to specify actions that will be performed during the panel is displaying
     */
    public void displayingPanel(){
    	
    }
    
}
